You can reference the link objects in your code by using the links property of the document object. The links property is an array that contains an entry for each link in a document.
Properties
target
Methods
xxx to be supplied
Event handlers
onClick onMouseOver
Examples
The following example creates a hypertext link to an anchor named javascript_intro.
<A HREF="#javascript_intro">Introduction to JavaScript</A>
The following example creates a hypertext link to a URL.
<A HREF="http://www.netscape.com">Netscape Home Page</A>
The built-in Math object has properties and methods for mathematical constants and functions. For example, the Math object's PI property has the value of pi.
Syntax
Math.propertyName
or
Math.methodName(parameters)
Description
You reference the constant PI as Math.PI. Constants are defined with the full precision of real numbers in JavaScript.
Similarly, you reference Math functions as methods. For example, the sine function is Math.sin(argument), where argument is the argument.
It is often convenient to use the with statement when a section of code uses several Math constants and methods, so you don't have to type "Math" repeatedly. For example,
with Math {
a = PI * r*r;
y = r*sin(theta)
x = r*cos(theta)
}
Properties
E LN10 LN2 PI SQRT1_2 SQRT2
Methods
abs acos asin atan ceil cos exp floor log max min pow random round sin sqrt tan
Event handlers
None. Built-in objects do not have event handlers.
A radioButton object is a set of radio buttons on an HTML form. A set of radio buttons lets the user choose one item from a list.
Syntax
To define a set of radio buttons, use standard HTML syntax with the addition of the onClick event handler:
<INPUT
TYPE="radio"
NAME="objectName"
VALUE="buttonValue"
[CHECKED]
[onClick="handlerText"]> textToDisplay
NAME should contain the same value for all radio buttons in a group.
Description
All radio buttons in a radio button group use the same name property. To access the individual radio buttons in your code, follow the object name with an index starting from zero, one for each button the same way you would for an array such as forms: document.forms[0].objectName[0] is the first, document.forms[0].objectName[1] is the second, etc.
Properties
checked defaultChecked index length name value
Methods
click
Event handlers
onClick
Examples
The following example defines a radio button group to choose among three catalogs. Each radio button is given the same name, NAME="choice", forming a group of buttons for which only one choice can be selected. The example also defines a text field that defaults to what was chosen via the radio buttons but that allows the user to type a nonstandard catalog name as well. JavaScript automatically sets the catalog name input field based on the radio buttons.
To define a reset button, use standard HTML syntax with the addition of the onClick event handler:
<INPUT
[NAME="objectName"]
TYPE="reset"
VALUE="buttonText"
[onClick="handlerText"]>
VALUE specifies the text to display on the button face and can be accessed using the value property.
Description
A reset button resets all elements in a form to their defaults.
Properties
name value
Methods
click
Event handlers
onClick
Examples
The following example displays a text object containing "CA". If the user types a different state abbreviation in the text object and then clicks the Clear Form button, the original value of "CA" is restored.
A selection object is a selection list or scrolling list on an HTML form. A selection list lets the user choose one item from a list. A scrolling list lets the user choose one or more items from a list.
Syntax
To define a selection object, use standard HTML syntax with the addition of the onBlur, onChange, and onFocus event handlers:
SIZE specifies the number of options visible when the form is displayed.
Description
You can reference the options of a selection object in your code by using the options property. The options property is an array that contains an entry for each option in a selection object. Each option has the properties listed below.
The options on selection objects can be updated dynamically. xxx NYI.
Properties
The selection object has the following properties: options selectedIndex
The options property has the following properties: defaultSelected index selected text value
Methods
click
Event handlers
onBlur onChange onFocus
Examples
The following example displays a selection list.
Choose the music type for your free CD:
<SELECT NAME="music_type_single">
<OPTION SELECTED> R&B <OPTION> Jazz <OPTION> Blues <OPTION> New Age</SELECT>
<P>Choose the music types for your free CDs:
<BR><SELECT NAME="music_type_multi" MULTIPLE>
<OPTION SELECTED> R&B <OPTION> Jazz <OPTION> Blues <OPTION> New Age</SELECT>
A submit object is a submit button on an HTML form.
Syntax
To define a submit button, use standard HTML syntax with the addition of the onClick event handler:
<INPUT
TYPE="submit"
NAME="objectName"
VALUE="buttonText"
[onClick="handlerText"]>
VALUE specifies the text to display on the button face and can be accessed using the value property.
Description
A submit button causes a form to be submitted.
Clicking a submit button submits a form to the program specified by the form's action property. This action always loads a new page into the client; it may be the same as the current page, if the action so specifies or is not specified.
A window object is the top-level object for each document, location, and history object group.
Syntax
xxx to be supplied
Description
The window object is the top-level object in the JavaScript client hierarchy. Because the existence of the current window is assumed, you don't have to reference the name of the window when you call its methods and assign its properties. For example, status="Jump to a new location" is a valid property assignment, and close() is a valid method call.
The self and window properties are synonyms for the current window, and you can optionally use them to refer to the current window. For example, you can close the current window by calling either window.close() or self.close(). You can use these properties to make your code more readable, or to disambiguate the property assignment self.status from a form called status.
See the methods and properties listed below for more examples.
You can reference a window's frame objects in your code by using the frames property. The frames property is an array that contains an entry for each frame in a window.
Properties
frames parent self top status defaultStatus
Methods
alert close confirm open prompt setTimeout clearTimeout